package com.pdg.mcplugin.questfor.config;

import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;


public class QuestConfig {
	private static final String AWARD = "award";
	private static final String INITIAL_DISTANCE = "initial_distance";
	private static final String INCREMENTAL_DISTANCE = "incremental_distance";
	private static final String MAXIMUM_QUESTS = "maximum_quests";
	private static final String INITIAL_XP_COST = "initial_xp_cost";
	private static final String INCREMENTAL_XP_COST = "incremental_xp_cost";
	private static final String PERMISSION = "permission";
	private static final int DEFAULT_INITIAL_XP_COST = 0;
	private static final int DEFAULT_INCREMENTAL_XP_COST = 0;
	private static final int DEFAULT_MAXIMUM_QUESTS = Integer.MAX_VALUE;
	private static final String DEFAULT_PERMISSION = PermissionChecker.PERMISSION_QUEST;
	private ItemStack award;
	private double initialDistance;
	private double incrementalDistance;
	private int maximumQuests;
	private int initialXpCost;
	private int incrementalXpCost;
	private String permission;
	public QuestConfig(ConfigurationSection theConfigurationSection){
		setAward(theConfigurationSection.getItemStack(AWARD));
		setInitialXpCost(theConfigurationSection.getInt(INITIAL_XP_COST,DEFAULT_INITIAL_XP_COST));
		setIncrementalXpCost(theConfigurationSection.getInt(INCREMENTAL_XP_COST,DEFAULT_INCREMENTAL_XP_COST));
		setInitialDistance(theConfigurationSection.getDouble(INITIAL_DISTANCE));
		setIncrementalDistance(theConfigurationSection.getDouble(INCREMENTAL_DISTANCE));
		setMaximumQuests(theConfigurationSection.getInt(MAXIMUM_QUESTS,DEFAULT_MAXIMUM_QUESTS));
		setPermission(theConfigurationSection.getString(PERMISSION,DEFAULT_PERMISSION));
	}
	public ItemStack getAward() {
		return award;
	}
	public void setAward(ItemStack award) {
		this.award = award;
	}
	public double getInitialDistance() {
		return initialDistance;
	}
	public void setInitialDistance(double initialDistance) {
		this.initialDistance = initialDistance;
	}
	public double getIncrementalDistance() {
		return incrementalDistance;
	}
	public void setIncrementalDistance(double incrementalDistance) {
		this.incrementalDistance = incrementalDistance;
	}
	public int getMaximumQuests() {
		return maximumQuests;
	}
	public void setMaximumQuests(int maximumQuests) {
		this.maximumQuests = maximumQuests;
	}
	public int getInitialXpCost() {
		return initialXpCost;
	}
	public void setInitialXpCost(int initialXpCost) {
		this.initialXpCost = initialXpCost;
	}
	public int getIncrementalXpCost() {
		return incrementalXpCost;
	}
	public void setIncrementalXpCost(int incrementalXpCost) {
		this.incrementalXpCost = incrementalXpCost;
	}
	public String getPermission() {
		return permission;
	}
	public void setPermission(String permission) {
		this.permission = permission;
	}
	public int calculateXpCost(int theNextLevel) {
		return getInitialXpCost() + theNextLevel * getIncrementalXpCost();
	}
	public double calculateDistance(int theNextLevel) {
		return getInitialDistance() + theNextLevel * getIncrementalDistance();
	}
}
